package com.core.gig.web.action;

import java.util.Collection;
import java.util.Collections;

import javax.servlet.http.HttpServletRequest;

import com.core.as.ASException;
import com.core.gig.as.ASCentroCusto;
import com.core.gig.as.ASFactory;
import com.core.gig.dto.AtivoImobilizadoDTO;
import com.core.gig.dto.AtivoPreImpressaoDTO;
import com.core.gig.dto.CentroCustoDTO;
import com.core.gig.util.AreaEnum;


/**
 * @author Lucas Ceni
 *
 */
public class AtivoPreImpressaoAction
		extends AtivoImobilizadoAction
{

	@Override
	protected AtivoImobilizadoDTO getDTO()
	{
		return new AtivoPreImpressaoDTO();
	}

	@Override
	protected AreaEnum getTipoAtivoImobilizado()
	{
		return AreaEnum.PREIMPRESSAO;
	}

	@SuppressWarnings("unchecked")
	@Override
	protected void setCentrosCusto(HttpServletRequest request)
	{
		CentroCustoDTO dto = new CentroCustoDTO();
		dto.setTipoCentro(AreaEnum.PREIMPRESSAO.name());
		Collection<CentroCustoDTO> centrosCusto = Collections.EMPTY_LIST;
		
		try
		{
			ASCentroCusto as = ASFactory.getInstance().getASCentroCusto();
			centrosCusto = as.pesquisarCentrosCusto(dto);
		}
		catch (ASException e)
		{
			addMessage(request, "uc001.msg.error.2", ICO_ALERT);
		}
		
		request.setAttribute("centrosCusto", centrosCusto);
	}
}